//
//  DescViewController.m
//  QuickCure
//
//  Created by 无梦生 on 16/9/13.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DescViewController.h"

@interface DescViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,weak)UITableView * descTableView;

@property (nonatomic,weak)UIImageView * iconImageView;

@property (nonatomic,weak)UIScrollView *icomView;

@property (nonatomic,strong)NSArray *array;

@property (nonatomic,strong)NSArray *iconArray;
@end

@implementation DescViewController

-(NSArray *)iconArray
{
    if (!_iconArray) {
        _iconArray = @[@"illness_img_person.png",@"xyg",@"jishiben",@"gt"];
    }
    return _iconArray;
}

-(NSArray *)array
{
    if (!_array) {
        _array = @[@"昵称",@"手机",@"资料",@"账号设置"];
    }
    return _array;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"账户信息";
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self creatUi];

    [self creatBtn];
    
}
-(void)creatIcon
{

    //实例化一个Header
    UIScrollView * iconView =[[UIScrollView alloc]init];
    //横竖滚动条消失
    iconView.showsVerticalScrollIndicator =NO;
    
    iconView.showsHorizontalScrollIndicator = NO;
    //可上下滚动
    iconView.alwaysBounceVertical = YES;
    
    iconView.backgroundColor = [UIColor grayColor];
    
    self.icomView = iconView;
    
    [self.view addSubview:iconView];
    //约束
    [iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(self.view);

        make.height.offset(290);
        
    }];
    
    //添加一个头像
    UIImageView * image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"heima"]];
    //切圆角
    image.layer.cornerRadius = 75;
    
    image.layer.masksToBounds = YES;
    //裁剪呈圆形
    image.clipsToBounds = YES;
    //填充
    image.contentMode = UIViewContentModeScaleAspectFit;
    
    self.iconImageView = image;
    
    [iconView addSubview:image];
    //约束
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.center.equalTo(iconView.center);
        
        make.width.height.offset(150);
        
    }];
    
}
//创建一个TableView
-(void)creatUi
{
    [self creatIcon];

    UITableView * descTableView = [[UITableView alloc]init];
    //代理
    descTableView.dataSource = self;
    
    descTableView.delegate = self;
    //将Table设置成不能滚动
    descTableView.scrollEnabled = NO;
    
    self.descTableView = descTableView;
    
    [self.view addSubview:descTableView];
    //约束
    [descTableView mas_makeConstraints:^(MASConstraintMaker *make) {
      
        make.left.right.equalTo(self.view);
       
        make.top.equalTo(self.icomView.bottom).offset(30);
        
        make.bottom.equalTo(self.view).offset(-150);
    }];
    
}
//创建删除的button
-(void)creatBtn
{
    //先实例化一个界面
    UIView *removeView = [[UIView alloc]init];
    
    removeView.backgroundColor = [UIColor clearColor];
    
    [self.view addSubview:removeView];
    //约束
    [removeView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.bottom.equalTo(self.view);
        
        make.top.equalTo(self.descTableView.bottom);
        
    }];
    //实例化一个Btn
    UIButton * btn = [[UIButton alloc]init];
    //设置背景图
    btn.layer.contents = (__bridge id _Nullable)([UIImage imageNamed:@"nav"].CGImage);
    //设置文字
    [btn setTitle:@"删除账号" forState:UIControlStateNormal];
    //设置文字颜色
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //响应事件
    [btn addTarget:self action:@selector(exitId) forControlEvents:UIControlEventTouchUpInside];
    
    [removeView addSubview:btn];
    //约束
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(removeView).offset(50);
        
        make.right.equalTo(removeView).offset(-50);
        
        make.top.equalTo(removeView).offset(30);
        
        make.height.offset(39);
        
    }];
    
    
    
}

//删除账号
-(void)exitId
{
    NSLog(@"删除");
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    
    cell.textLabel.text = self.array[indexPath.row];
    //字体大小
    cell.textLabel.font = [UIFont systemFontOfSize:15];
    //设置箭头
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    //设置图片
    cell.imageView.image = [UIImage imageNamed:self.iconArray[indexPath.row]];
    
    return cell;
}



@end
